/**
 * @description: 低代码文件持久化类
 * @param {domTree} domTree dom树
 * @param {model} model 数据模型
 * @param {eventCollection} eventCollection 事件集合
 * @param {dataSource} dataSource 数据源
 * @param {globalConfig} globalConfig 页面配置信息
 */
export type LowCodeType = {
    domTree: any,
    model?: any,
    eventCollection?: Array<EventType>;
    dataSource?: Array<DataSourceType>;
    globalConfig?: GlobalConfig
}
/**
 * @description: 低代码文件控制器
 */
export interface LowCodeImp extends LowCodeType {
    disabled?: boolean;
    dataCenter: any;
    [x: string]: any;
    currentKey: string;
    model: any;
    eventCollection: Array<EventType>;
    dataSource: Array<DataSourceType>;
    modelController: ModelImp,//modelController 数据控制类
    eventCenterController: EventCenterImp,//eventCenterController 事件控制器
    dataSourceController: DataSourceImp,//dataSourceController 数据源控制器
    updateMetaRefresh: () => void;
    buildDomTree: () => void;
    registrationControl: () => void;
    addComponent: (com: ComponentImp | CellImp) => ComponentImp | CellImp,
    setcurrentKey: (key: string) => void,
    removeComponent: (key: string) => void,
    copyComponent: (com: ComponentImp, newkey: boolean) => ComponentImp,
}
/**
 * @description: 组件控制器
 */
export interface ComponentImp {
    key: string;
    type: string;
    name: string;
    model: string[];
    selector: string,
    group: string;
    describe: string;
    nestedChain: string;
    options: any;
    style?: any;
    items?: Array<ComponentImp | CellImp>;
    updateMetaRefresh?: () => void;
    getLowCodeInstance?: () => LowCodeImp;
    modelBing?: () => void
}
/**
 * @description: 单元格类型
 */
export interface CellImp<T = any> {
    key: string;
    type: string;
    options?: any;
    items?: Array<T>;
}
/**
 * @description: 数据控制器
 */
export interface ModelImp {
    modelTree: any;
    modelKeyList: { [key: string]: string }[];
    buildModelTree: () => void;
    buildModelKeyList: () => void;
    saveModel: (key: string, model: any) => void;
    selectModel: (key: string) => any;
    removeModel: (key: string) => void
}
/**
 * @description: 事件控制器
 */
export interface EventCenterImp<T = any> {
    init: () => void;
    addEvent: (type: string, describe: string, options: any, event: string) => void;
    editorEvent: (type: string, code: string, options: any, describe: string, event: string) => void
    removeEvent: (code: string) => void
    on: (key: string, listener: Function) => EventCenterImp;
    fire: (key: string, ...params: any[]) => Promise<T> | boolean;
    off: (key: string, listener: string) => void;
}
/**
 * @description: 事件类型
 */
export interface EventType {
    code: string;
    type: string;
    options?: any;
    describe: string,
    func: string,
}

/**
 * @description: 数据源类型
 */
export interface DataSourceType {
    key: string;
    name: string;
    url: string;
    method: string;
    auto: boolean;
}
/**
 * @description: 数据源控制器
 */
export interface DataSourceImp {
    [x: string]: any;
    currentDataSource: DataSourceType | null;
    init: () => void;
    addDataSource: () => DataSourceType;
    copyDataSource: (key: string) => void;
    removeDataSource: (key: string) => boolean;
    updateDataSource: (dataSource: DataSourceType) => boolean
}
/**
 * @description: 页面配置信息类
 */
export interface GlobalConfig {
    labelWidth: number,
    labelPosition: "left" | "right" | "top",
    size: "default" | "large" | "small"
}

/**
 * @description: 选择器类型
 */
export interface SelectorImp {
    find: (name: string) => SelectorImp | boolean;
    set: (key: string, value: any) => SelectorImp
    get: (key?: string) => unknown
}






